﻿@using KnockoutJS.Web.Extensions
@model KnockoutJS.Web.ViewModels.CartViewModel

<a id="cart" href="@Url.Action("Index","Carts")" class="text-center" data-bind="click:showCart">
    <span class="glyphicon glyphicon-shopping-cart"></span>
    <span class="badge" data-bind="text:cart.cartItems().length;"></span>
</a>

<div id="cart-summary" style="display:none;">
    <span data-bind="visible:cart.cartItems().length == 0">当前购物车为空！</span>
    <div data-bind="visible:cart.cartItems().length > 0">
        <ol style="padding-left:15px;">
            <!--ko foreach :{data:cart.cartItems,afterAdd:fadeIn }-->
            <li data-bind="text:book.title"></li>
            <!--/ko-->
        </ol>
        <p><strong>总计:</strong>￥<span data-bind="text:cart.total()"></span></p>
        <br />
        <a href="@Url.Action("Index","Carts")" class="btn btn-primary">详情</a>
    </div>
</div>
<script>
    var cartSummaryData = @Html.HtmlConvertToJson(Model);
</script>
